﻿using Dapper;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using OMG.Fill.Potato.Model;
using OMG.Fill.Potato.Model.Ent;
using OMG.Fill.Potato.Service;
using ProjectShare;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace OMG.Fill.Potato.Services
{
    /// <summary>
    /// 各生产季马铃薯生产情况统计表通用操作类
    /// </summary>
    public class PotSeasonProductServices: PotSeasonProducts
    {
        public Pager<List<PotSeasonProductEntity>> GetPageList(PotSeasonProductQuery query)
        {
            Pager<List<PotSeasonProductEntity>> obj = new Pager<List<PotSeasonProductEntity>>();
            var paramlist = new DynamicParameters();
            string strWhereSql = "";//from 表在下面，需完善其他查询条件在这里接的写，格式为："and xxx=@xxx空格,如下注释部分代码所示："
            //if (!string.IsNullOrEmpty(query.GroupCode))
            //{
            //  strWhereSql += "and GroupCode = @GroupCode ";
            //  paramlist.Add("GroupCode", query.GroupCode);
            //}
            string strFromSql = "from dbo.T_PotSeasonProduct where 1=1 " + strWhereSql;
            string strTotal = "select count(1)" + strFromSql + strWhereSql;
            string strOrderSql = "";//自定义完成order by语句
            string strSql = @"select * from (select *,ROW_NUMBER() over (order by Id ) as RowNumber " + strFromSql + ") as t ";
            strSql += "where t.RowNumber between  @minRow and @maxRow" + strOrderSql;
            paramlist.Add("minRow", query.MinRow);
            paramlist.Add("maxRow", query.MaxRow);
            try
            {
                using (var dbCon = ConnectFactory.GetOpenConnection())
                {
                    obj.rows = dbCon.Query<PotSeasonProductEntity>(strSql,paramlist).ToList();
                    obj.total = dbCon.Query<int>(strTotal,paramlist).FirstOrDefault();
                    obj.status = DefaultKey.SuccessResult;
                    obj.message = "获取成功！";
                    dbCon.Dispose();//数据库连接释放
                    return obj;
                }
            }
            catch (Exception ex)
            {
                obj.status = DefaultKey.ErrorResult;
                obj.message = ex.ToString().Trim();
                LogHelper.ErrorLog("获取各生产季马铃薯生产情况统计表分页列表失败", ex);
                return obj;
            }
        }
        public ResResult<List<PotSeasonProductEntity>> GetValidData(string AreaCode, string FillInYear, string TimesCycle)
        {
            ResResult<List<PotSeasonProductEntity>> obj = new ResResult<List<PotSeasonProductEntity>>();
            List<PotSeasonProductEntity> list = new List<PotSeasonProductEntity>();
            ReportServices reportService = new ReportServices();
            string strSql = @"select * from dbo.T_PotSeasonProduct where ReportId = @ReportId";
            string rSql = @"select * from dbo.T_Report where ReportCode='PotSeasonProduct' and  AreaCode = @AreaCode and FillInYear =@FillInYear and TimesCycle = @TimesCycle";
            try
            {
                using (var dbCon = ConnectFactory.GetOpenConnection())
                {
                    string ReportId = dbCon.Query<ReportEntity>(rSql, new { AreaCode = AreaCode, FillInYear = FillInYear, TimesCycle  = TimesCycle }).FirstOrDefault().Id;
                    if (reportService.CheckRepCount(ReportId, "T_PotSeasonProduct"))
                    {
                        if (TimesCycle.Equals("3"))
                        {
                            string[] sdicts = { "冬作", "小春作", "早春作" };
                            string[] svalues = { "3-1", "3-2", "3-3" };
                            for (int i = 0; i < 3; i++)
                            {
                                PotSeasonProductEntity entity = new PotSeasonProductEntity();
                                entity.ReportId = ReportId;
                                entity.SeasonDict = sdicts[i];
                                entity.SeasonValue = svalues[i];
                                list.Add(entity);
                            }
                        }
                        else
                        {
                            PotSeasonProductEntity entity = new PotSeasonProductEntity();
                            entity.ReportId = ReportId;
                            entity.SeasonDict = DataDict.Instance["QuarterCycleValue"][TimesCycle];
                            entity.SeasonValue = TimesCycle;
                            list.Add(entity);
                        }

                    }
                    else
                    {
                        list = dbCon.Query<PotSeasonProductEntity>(strSql, new { ReportId = ReportId }).ToList();
                    }
                    obj.model = list;
                    obj.status = DefaultKey.SuccessResult;
                    obj.message = "获取成功！";
                    dbCon.Dispose();//数据库连接释放
                    return obj;
                }
            }
            catch (Exception ex)
            {
                obj.status = DefaultKey.ErrorResult;
                obj.message = ex.ToString().Trim();
                LogHelper.ErrorLog("获取各生产季马铃薯生产情况统计表对象信息失败", ex);
                return obj;
            }
        }
        public List<PotSeasonProductEntity> ExcelToModel(string pathName, string fileSuffix, string ReportId)
        {

            IWorkbook workbook = null;
            ISheet sheet = null;
            List<PotSeasonProductEntity> list = new List<PotSeasonProductEntity>();
            FileStream fs = new FileStream(pathName, FileMode.Open, FileAccess.Read);
            switch (fileSuffix)
            {
                case ".xls":
                    workbook = new HSSFWorkbook(fs);
                    break;
                case ".xlsx":
                    workbook = new XSSFWorkbook(fs);
                    break;
                default:
                    workbook = new HSSFWorkbook(fs);
                    break;
            }
            sheet = workbook.GetSheetAt(0);
            if (sheet != null)
            {
                int startRow = 4;
                IRow firstRow = sheet.GetRow(startRow);//从第5行开始读
                int cellCount = firstRow.LastCellNum;//获取列数

                //获取所有数据的行数
                int rowCount = 0;
                for (int i = startRow; i <= sheet.LastRowNum; i++)
                {
                    IRow row = sheet.GetRow(i);
                    if (row != null)
                    {
                        rowCount = sheet.GetRow(i).RowNum;
                    }
                    else
                    {
                        break;
                    }
                }
                for (int i = startRow; i <= rowCount; i++)
                {
                    IRow row = sheet.GetRow(i);
                    PotSeasonProductEntity model = new PotSeasonProductEntity();
                    if (row.GetCell(0) != null)
                        model.SeasonDict = row.GetCell(0).ToString();
                    if (row.GetCell(1) != null)
                        model.PHTime = row.GetCell(1).ToString();
                    //if (row.GetCell(2) != null)
                    //    model.MainVariety = row.GetCell(2).ToString();
                    if (row.GetCell(2) != null)
                    {
                        if (row.GetCell(2).CellType == CellType.Formula)
                        {
                            model.TotalArea = Decimal.Round(Convert.ToDecimal(row.GetCell(2).NumericCellValue), 4);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(2).ToString()))
                            {
                                model.TotalArea = Convert.ToDecimal(row.GetCell(2).ToString());
                            }
                            else
                            {
                                model.TotalArea = 0;
                            }
                        }
                    }
                    else
                    {
                        model.TotalArea = 0;
                    }

                    if (row.GetCell(3) != null)
                    {
                        if (row.GetCell(3).CellType == CellType.Formula)
                        {
                            model.TotalYield = Decimal.Round(Convert.ToDecimal(row.GetCell(3).NumericCellValue), 4);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(3).ToString()))
                            {
                                model.TotalYield = Convert.ToDecimal(row.GetCell(3).ToString());
                            }
                            else
                            {
                                model.TotalYield = 0;
                            }
                        }
                    }
                    else
                    {
                        model.TotalYield = 0;
                    }

                    //if (row.GetCell(4) != null)
                    //{
                    //    if (row.GetCell(4).CellType == CellType.Formula)
                    //    {
                    //        model.AvgMuYield = Decimal.Round(Convert.ToDecimal(row.GetCell(4).NumericCellValue), 2);
                    //    }
                    //    else
                    //    {
                    //        if (DataCheck.isNumber(row.GetCell(4).ToString()))
                    //        {
                    //            model.AvgMuYield = Convert.ToDecimal(row.GetCell(4).ToString());
                    //        }
                    //        else
                    //        {
                    //            model.AvgMuYield = null;
                    //        }
                    //    }
                    //}

                    //if (row.GetCell(5) != null)
                    //{
                    //    if (row.GetCell(5).CellType == CellType.Formula)
                    //    {
                    //        model.MuOutput = Decimal.Round(Convert.ToDecimal(row.GetCell(5).NumericCellValue), 1);
                    //    }
                    //    else
                    //    {
                    //        if (DataCheck.isNumber(row.GetCell(5).ToString()))
                    //        {
                    //            model.MuOutput = Convert.ToDecimal(row.GetCell(5).ToString());
                    //        }
                    //        else
                    //        {
                    //            model.MuOutput = null;
                    //        }
                    //    }
                    //}

                    if (row.GetCell(6) != null)
                    {
                        if (row.GetCell(6).CellType == CellType.Formula)
                        {
                            model.TotalOutput = Decimal.Round(Convert.ToDecimal(row.GetCell(6).NumericCellValue), 4);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(6).ToString()))
                            {
                                model.TotalOutput = Convert.ToDecimal(row.GetCell(6).ToString());
                            }
                            else
                            {
                                model.TotalOutput = 0;
                            }
                        }
                    }
                    else
                    {
                        model.TotalOutput = 0;
                    }


                    if (model.TotalArea != null && model.TotalArea != 0)
                    {
                        if (model.TotalYield != null)
                        {
                            model.AvgMuYield = Decimal.Round(Convert.ToDecimal(model.TotalYield / model.TotalArea * 1000), 2);
                        }
                        if (model.TotalOutput != null)
                        {
                            model.MuOutput = Decimal.Round(Convert.ToDecimal(model.TotalOutput / model.TotalArea), 1);
                        }

                    }
                   



                    if (row.GetCell(7) != null)
                        model.TechModel = row.GetCell(7).ToString();

                    if (row.GetCell(8) != null)
                    {
                        if (row.GetCell(8).CellType == CellType.Formula)
                        {
                            model.tdSeedArea = Decimal.Round(Convert.ToDecimal(row.GetCell(8).NumericCellValue), 2);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(8).ToString()))
                            {
                                model.tdSeedArea = Convert.ToDecimal(row.GetCell(8).ToString());
                            }
                            else
                            {
                                model.tdSeedArea = 0;
                            }
                        }
                    }
                    else
                    {
                        model.tdSeedArea = 0;
                    }


                    if(model.tdSeedArea !=null &&model.TotalArea != null && model.TotalArea != 0)
                    {
                        model.SeedCoverage = Decimal.Round(Convert.ToDecimal(model.tdSeedArea / model.TotalArea*100),2);
                    }

                    if (row.GetCell(9) != null)
                    {
                        if (row.GetCell(9).CellType == CellType.Formula)
                        {
                            model.MulchArea = Decimal.Round(Convert.ToDecimal(row.GetCell(9).NumericCellValue), 4);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(9).ToString()))
                            {
                                model.MulchArea = Convert.ToDecimal(row.GetCell(9).ToString());
                            }
                            else
                            {
                                model.MulchArea = 0;
                            }
                        }
                    }
                    else
                    {
                        model.MulchArea = 0;
                    }

                    if (row.GetCell(10) != null)
                    {
                        if (row.GetCell(10).CellType == CellType.Formula)
                        {
                            model.DripArea = Decimal.Round(Convert.ToDecimal(row.GetCell(10).NumericCellValue), 4);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(10).ToString()))
                            {
                                model.DripArea = Convert.ToDecimal(row.GetCell(10).ToString());
                            }
                            else
                            {
                                model.DripArea = 0;
                            }
                        }
                    }
                    else{
                        model.DripArea = 0;
                    }

                    if (row.GetCell(11) != null)
                    {
                        if (row.GetCell(11).CellType == CellType.Formula)
                        {
                            model.FertilizerArea = Decimal.Round(Convert.ToDecimal(row.GetCell(11).NumericCellValue), 4);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(11).ToString()))
                            {
                                model.FertilizerArea = Convert.ToDecimal(row.GetCell(11).ToString());
                            }
                            else
                            {
                                model.FertilizerArea = 0;
                            }
                        }
                    }
                    else
                    {
                        model.FertilizerArea = 0;
                    }

                    if (row.GetCell(12) != null)
                    {
                        if (row.GetCell(12).CellType == CellType.Formula)
                        {
                            model.NoCultivationArea = Decimal.Round(Convert.ToDecimal(row.GetCell(12).NumericCellValue), 4);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(12).ToString()))
                            {
                                model.NoCultivationArea = Convert.ToDecimal(row.GetCell(12).ToString());
                            }
                            else
                            {
                                model.NoCultivationArea = 0;
                            }
                        }
                    }
                    else
                    {
                        model.NoCultivationArea = 0;
                    }
                    ///////////////////////////////////
                    if (row.GetCell(13) != null)
                    {
                        if (row.GetCell(13).CellType == CellType.Formula)
                        {
                            model.JZArea = Decimal.Round(Convert.ToDecimal(row.GetCell(13).NumericCellValue), 4);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(13).ToString()))
                            {
                                model.JZArea = Convert.ToDecimal(row.GetCell(13).ToString());
                            }
                            else
                            {
                                model.JZArea = 0;
                            }
                        }
                    }
                    else
                    {
                        model.JZArea = 0;
                    }

                    if (row.GetCell(14) != null)
                    {
                        if (row.GetCell(14).CellType == CellType.Formula)
                        {
                            model.JZYield = Decimal.Round(Convert.ToDecimal(row.GetCell(14).NumericCellValue), 4);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(14).ToString()))
                            {
                                model.JZYield = Convert.ToDecimal(row.GetCell(14).ToString());
                            }
                            else
                            {
                                model.JZYield = 0;
                            }
                        }
                    }
                    else
                    {
                        model.JZYield = 0;
                    }
                    if (model.JZArea != null && model.JZArea != 0)
                    {
                        if (model.JZYield != null)
                        {
                            model.JZAvgMuYield = Decimal.Round(Convert.ToDecimal(model.JZYield / model.JZArea*1000), 2);
                        }

                    }
                    if (row.GetCell(15) != null)
                    {
                        if (row.GetCell(15).CellType == CellType.Formula)
                        {
                            model.JZMuOutput = Decimal.Round(Convert.ToDecimal(row.GetCell(15).NumericCellValue), 1);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(15).ToString()))
                            {
                                model.JZMuOutput = Convert.ToDecimal(row.GetCell(15).ToString());
                            }
                            else
                            {
                                model.JZMuOutput = 0;
                            }
                        }
                    }
                    else
                    {
                        model.JZMuOutput = 0;
                    }

                    if (row.GetCell(16) != null)
                    {
                        if (row.GetCell(16).CellType == CellType.Formula)
                        {
                            model.JZDensity = Decimal.Round(Convert.ToDecimal(row.GetCell(16).NumericCellValue), 0);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(16).ToString()))
                            {
                                model.JZDensity = Convert.ToDecimal(row.GetCell(16).ToString());
                            }
                            else
                            {
                                model.JZDensity = 0;
                            }
                        }
                    }
                    else
                    {
                        model.JZDensity = 0;
                    }
                    if (row.GetCell(17) != null)
                        model.JZTechModel = row.GetCell(17).ToString();
                    /////////////////////////////////////////////
                    if (row.GetCell(18) != null)
                    {
                        if (row.GetCell(18).CellType == CellType.Formula)
                        {
                            model.JTArea = Decimal.Round(Convert.ToDecimal(row.GetCell(18).NumericCellValue), 4);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(18).ToString()))
                            {
                                model.JTArea = Convert.ToDecimal(row.GetCell(18).ToString());
                            }
                            else
                            {
                                model.JTArea = 0;
                            }
                        }
                    }
                    else
                    {
                        model.JTArea = 0;
                    }

                    if (row.GetCell(19) != null)
                    {
                        if (row.GetCell(19).CellType == CellType.Formula)
                        {
                            model.JTYield = Decimal.Round(Convert.ToDecimal(row.GetCell(19).NumericCellValue),4);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(19).ToString()))
                            {
                                model.JTYield = Convert.ToDecimal(row.GetCell(19).ToString());
                            }
                            else
                            {
                                model.JTYield = 0;
                            }
                        }
                    }
                    else
                    {
                        model.JTYield = 0;
                    }

                    if (model.JTArea != null && model.JTArea != 0)
                    {
                        if (model.JTYield != null)
                        {
                            model.JTAvgMuYield = Decimal.Round(Convert.ToDecimal(model.JTYield / model.JTArea*1000), 2);
                        }

                    }
                    if (row.GetCell(20) != null)
                    {
                        if (row.GetCell(20).CellType == CellType.Formula)
                        {
                            model.JTMixMuYield = Decimal.Round(Convert.ToDecimal(row.GetCell(20).NumericCellValue), 2);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(20).ToString()))
                            {
                                model.JTMixMuYield = Convert.ToDecimal(row.GetCell(20).ToString());
                            }
                            else
                            {
                                model.JTMixMuYield = 0;
                            }
                        }
                    }
                    else
                    {
                        model.JTMixMuYield = 0;
                    }

                    if (row.GetCell(21) != null)
                    {
                        if (row.GetCell(21).CellType == CellType.Formula)
                        {
                            model.JTMixMuOutput = Decimal.Round(Convert.ToDecimal(row.GetCell(21).NumericCellValue), 1);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(21).ToString()))
                            {
                                model.JTMixMuOutput = Convert.ToDecimal(row.GetCell(21).ToString());
                            }
                            else
                            {
                                model.JTMixMuOutput = 0;
                            }
                        }
                    }
                    else
                    {
                        model.JTMixMuOutput = 0;
                    }
                    if (row.GetCell(22) != null)
                        model.JTTechModel = row.GetCell(22).ToString();
                    /////////////////////////////////////////////////////
                    if (row.GetCell(23) != null)
                    {
                        if (row.GetCell(23).CellType == CellType.Formula)
                        {
                            model.MechPlantArea = Decimal.Round(Convert.ToDecimal(row.GetCell(23).NumericCellValue), 4);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(23).ToString()))
                            {
                                model.MechPlantArea = Convert.ToDecimal(row.GetCell(23).ToString());
                            }
                            else
                            {
                                model.MechPlantArea = 0;
                            }
                        }
                    }
                    else
                    {
                        model.MechPlantArea = 0;
                    }

                    if (row.GetCell(24) != null)
                    {
                        if (row.GetCell(24).CellType == CellType.Formula)
                        {
                            model.MechCultivationArea = Decimal.Round(Convert.ToDecimal(row.GetCell(24).NumericCellValue), 4);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(24).ToString()))
                            {
                                model.MechCultivationArea = Convert.ToDecimal(row.GetCell(24).ToString());
                            }
                            else
                            {
                                model.MechCultivationArea = 0;
                            }
                        }
                    }
                    else
                    {
                        model.MechCultivationArea = 0;
                    }

                    if (row.GetCell(25) != null)
                    {
                        if (row.GetCell(25).CellType == CellType.Formula)
                        {
                            model.MechFertilizerArea = Decimal.Round(Convert.ToDecimal(row.GetCell(25).NumericCellValue), 4);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(25).ToString()))
                            {
                                model.MechFertilizerArea = Convert.ToDecimal(row.GetCell(25).ToString());
                            }
                            else
                            {
                                model.MechFertilizerArea = 0;
                            }
                        }
                    }
                    else
                    {
                        model.MechFertilizerArea = 0;
                    }

                    if (row.GetCell(26) != null)
                    {
                        if (row.GetCell(26).CellType == CellType.Formula)
                        {
                            model.MechPesticideArea = Decimal.Round(Convert.ToDecimal(row.GetCell(26).NumericCellValue), 4);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(26).ToString()))
                            {
                                model.MechPesticideArea = Convert.ToDecimal(row.GetCell(26).ToString());
                            }
                            else
                            {
                                model.MechPesticideArea = 0;
                            }
                        }
                    }
                    else
                    {
                        model.MechPesticideArea = 0;
                    }

                    if (row.GetCell(27) != null)
                    {
                        if (row.GetCell(27).CellType == CellType.Formula)
                        {
                            model.MechHarvestArea = Decimal.Round(Convert.ToDecimal(row.GetCell(27).NumericCellValue), 4);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(27).ToString()))
                            {
                                model.MechHarvestArea = Convert.ToDecimal(row.GetCell(27).ToString());
                            }
                            else
                            {
                                model.MechHarvestArea = 0;
                            }
                        }
                    }
                    else
                    {
                        model.MechHarvestArea = 0;
                    }
                    //////////////////////////////
                    if (row.GetCell(28) != null)
                    {
                        if (row.GetCell(28).CellType == CellType.Formula)
                        {
                            model.SeedCost = Decimal.Round(Convert.ToDecimal(row.GetCell(28).NumericCellValue), 1);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(28).ToString()))
                            {
                                model.SeedCost = Convert.ToDecimal(row.GetCell(28).ToString());
                            }
                            else
                            {
                                model.SeedCost = 0;
                            }
                        }
                    }
                    else
                    {
                        model.SeedCost = 0;
                    }

                    if (row.GetCell(29) != null)
                    {
                        if (row.GetCell(29).CellType == CellType.Formula)
                        {
                            model.FertilizerCost = Decimal.Round(Convert.ToDecimal(row.GetCell(29).NumericCellValue), 1);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(29).ToString()))
                            {
                                model.FertilizerCost = Convert.ToDecimal(row.GetCell(29).ToString());
                            }
                            else
                            {
                                model.FertilizerCost = 0;
                            }
                        }
                    }
                    else
                    {
                        model.FertilizerCost = 0;
                    }

                    if (row.GetCell(30) != null)
                    {
                        if (row.GetCell(30).CellType == CellType.Formula)
                        {
                            model.PesticideCost = Decimal.Round(Convert.ToDecimal(row.GetCell(30).NumericCellValue), 1);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(30).ToString()))
                            {
                                model.PesticideCost = Convert.ToDecimal(row.GetCell(30).ToString());
                            }
                            else
                            {
                                model.PesticideCost = 0;
                            }
                        }
                    }
                    else
                    {
                        model.PesticideCost = 0;
                    }

                    if (row.GetCell(31) != null)
                    {
                        if (row.GetCell(31).CellType == CellType.Formula)
                        {
                            model.MulchCost = Decimal.Round(Convert.ToDecimal(row.GetCell(31).NumericCellValue), 1);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(31).ToString()))
                            {
                                model.MulchCost = Convert.ToDecimal(row.GetCell(31).ToString());
                            }
                            else
                            {
                                model.MulchCost = 0;
                            }
                        }
                    }
                    else
                    {
                        model.MulchCost = 0;
                    }

                    if (row.GetCell(32) != null)
                    {
                        if (row.GetCell(32).CellType == CellType.Formula)
                        {
                            model.LaborCost = Decimal.Round(Convert.ToDecimal(row.GetCell(32).NumericCellValue), 1);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(32).ToString()))
                            {
                                model.LaborCost = Convert.ToDecimal(row.GetCell(32).ToString());
                            }
                            else
                            {
                                model.LaborCost = 0;
                            }
                        }
                    }
                    else
                    {
                        model.LaborCost = 0;
                    }

                    if (row.GetCell(33) != null)
                    {
                        if (row.GetCell(33).CellType == CellType.Formula)
                        {
                            model.OtherCost = Decimal.Round(Convert.ToDecimal(row.GetCell(33).NumericCellValue), 1);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(33).ToString()))
                            {
                                model.OtherCost = Convert.ToDecimal(row.GetCell(33).ToString());
                            }
                            else
                            {
                                model.OtherCost = 0;
                            }
                        }
                    }
                    else
                    {
                        model.OtherCost = 0;
                    }

                    //if (row.GetCell(34) != null)
                    //{
                    //    if (row.GetCell(34).CellType == CellType.Formula)
                    //    {
                    //        model.TotalCost = Decimal.Round(Convert.ToDecimal(row.GetCell(34).NumericCellValue), 1);
                    //    }
                    //    else
                    //    {
                    //        if (DataCheck.isNumber(row.GetCell(34).ToString()))
                    //        {
                    //            model.TotalCost = Convert.ToDecimal(row.GetCell(34).ToString());
                    //        }
                    //        else
                    //        {
                    //            model.TotalCost = null;
                    //        }
                    //    }
                    //}
                    decimal TotalCost = 0;
                    if(model.SeedCost != null)
                    {
                        TotalCost += (decimal)model.SeedCost;
                    }
                    if (model.FertilizerCost != null)
                    {
                        TotalCost += (decimal)model.FertilizerCost;
                    }
                    if (model.PesticideCost != null)
                    {
                        TotalCost += (decimal)model.PesticideCost;
                    }
                    if (model.MulchCost != null)
                    {
                        TotalCost += (decimal)model.MulchCost;
                    }
                    if (model.LaborCost != null)
                    {
                        TotalCost += (decimal)model.LaborCost;
                    }
                    if (model.OtherCost != null)
                    {
                        TotalCost += (decimal)model.OtherCost;
                    }
                    model.TotalCost = Decimal.Round(TotalCost, 1);


                    if (row.GetCell(35) != null)
                    {
                        if (row.GetCell(35).CellType == CellType.Formula)
                        {
                            model.OAvgMuYield = Decimal.Round(Convert.ToDecimal(row.GetCell(35).NumericCellValue), 2);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(35).ToString()))
                            {
                                model.OAvgMuYield = Convert.ToDecimal(row.GetCell(35).ToString());
                            }
                            else
                            {
                                model.OAvgMuYield = 0;
                            }
                        }
                    }
                    else
                    {
                        model.OAvgMuYield = 0;
                    }

                    if (row.GetCell(36) != null)
                    {
                        if (row.GetCell(36).CellType == CellType.Formula)
                        {
                            model.OAvgPrice = Decimal.Round(Convert.ToDecimal(row.GetCell(36).NumericCellValue), 2);
                        }
                        else
                        {
                            if (DataCheck.isNumber(row.GetCell(36).ToString()))
                            {
                                model.OAvgPrice = Convert.ToDecimal(row.GetCell(36).ToString());
                            }
                            else
                            {
                                model.OAvgPrice = 0;
                            }
                        }
                    }
                    else
                    {
                        model.OAvgPrice = 0;
                    }

                    //if (row.GetCell(37) != null)
                    //{
                    //    if (row.GetCell(37).CellType == CellType.Formula)
                    //    {
                    //        model.OTotalOutput = Decimal.Round(Convert.ToDecimal(row.GetCell(37).NumericCellValue), 1);
                    //    }
                    //    else
                    //    {
                    //        if (DataCheck.isNumber(row.GetCell(37).ToString()))
                    //        {
                    //            model.OTotalOutput = Convert.ToDecimal(row.GetCell(37).ToString());
                    //        }
                    //        else
                    //        {
                    //            model.OTotalOutput = null;
                    //        }
                    //    }
                    //}
                    if (model.OAvgMuYield != null && model.OAvgPrice != null)
                        model.OTotalOutput = Decimal.Round(Convert.ToDecimal(model.OAvgPrice * model.OAvgMuYield),1);

                    //if (row.GetCell(38) != null)
                    //{
                    //    if (row.GetCell(38).CellType == CellType.Formula)
                    //    {
                    //        model.Income = Decimal.Round(Convert.ToDecimal(row.GetCell(38).NumericCellValue), 1);
                    //    }
                    //    else
                    //    {
                    //        if (DataCheck.isNumber(row.GetCell(38).ToString()))
                    //        {
                    //            model.Income = Convert.ToDecimal(row.GetCell(38).ToString());
                    //        }
                    //        else
                    //        {
                    //            model.Income = null;
                    //        }
                    //    }
                    //}
                    if(model.OTotalOutput !=null && model.TotalCost != null)
                        model.Income = Decimal.Round(Convert.ToDecimal(model.OTotalOutput - model.TotalCost), 1);

                    model.ReportId = ReportId;
                    list.Add(model);
                }

            }
           return list;
        }
        public ResResult<List<SeasonProductStatisModel>> getStatisListData(string AreaCode, string FillInYear, string TimesCycle, string SeasonDict)
        {
           ResResult<List<SeasonProductStatisModel>> obj = new ResResult<List<SeasonProductStatisModel>>();
           List<SeasonProductStatisModel> list = new List<SeasonProductStatisModel>();
            AreaServices areaservices = new AreaServices();
            if (AreaCode.Equals("530000000000"))
            {
                list = getProvinStatisList(FillInYear, TimesCycle, SeasonDict);
            }
            else if (AreaCode.Substring(4, 8).Equals("00000000"))
            {
                list = getCityStatisList(AreaCode, FillInYear, TimesCycle, SeasonDict);
            }
            obj.model = list;
            obj.status = DefaultKey.SuccessResult;
            obj.message = "获取成功";
            return obj;
        }
        public List<SeasonProductStatisModel> getProvinStatisList(string FillInYear, string TimesCycle,string SeasonDict)
        {
            List<SeasonProductStatisModel> list = new List<SeasonProductStatisModel>();
            string strSql = "select  ta.FullName AreaName,tt.* from( ";
            strSql += " select case when grouping(t1.ParentCode)=1 then '530000000000' else ParentCode end AreaCode, ";
            strSql += " isnull(sum(t3.TotalArea),0.00) TotalArea, ";
            strSql += " isnull(sum(t3.TotalYield),0.00) TotalYield, ";
            strSql += " isnull(sum(t3.TotalOutput),0.00) TotalOutput, ";
            strSql += " isnull(sum(t3.tdSeedArea),0.00) tdSeedArea,";
            strSql += " isnull(sum(t3.MulchArea),0.00) MulchArea, ";
            strSql += " isnull(sum(t3.DripArea),0.00) DripArea, ";
            strSql += " isnull(sum(t3.FertilizerArea),0.00) FertilizerArea, ";
            strSql += " isnull(sum(t3.NoCultivationArea),0.00) NoCultivationArea, ";
            strSql += " isnull(sum(t3.JZArea),0.00) JZArea, ";
            strSql += " isnull(sum(t3.JZYield),0.00) JZYield,  ";
            strSql += " isnull(cast(sum(t3.JZArea*t3.JZMuOutput)as decimal(10,4)),0.00) JZOutput, ";
            strSql += " isnull(cast(sum(t3.JZDensity)/(case when count(case when t3.JZDensity !=0 then 1 else null end) = 0 then 1 else count(case when t3.JZDensity !=0 then 1 else null end) end )as decimal(10,2)),0.00) JZDensity,";
            strSql += " isnull(sum(t3.JTArea),0.00) JTArea, ";
            strSql += " isnull(sum(t3.JTYield),0.00) JTYield, ";
            strSql += " isnull(cast(sum(t3.JTArea*t3.JTMixMuYield/1000)as decimal(10,4)),0.00)JTMixYield, ";
            strSql += " isnull(cast(sum(t3.JTArea*t3.JTMixMuOutput)as decimal(10,4)),0.00)JTMixOutput,";
            strSql += " isnull(sum(t3.MechPlantArea),0.00) MechPlantArea, ";
            strSql += " isnull(sum(t3.MechCultivationArea),0.00) MechCultivationArea, ";
            strSql += " isnull(sum(t3.MechFertilizerArea),0.00) MechFertilizerArea, ";
            strSql += " isnull(sum(t3.MechPesticideArea),0.00) MechPesticideArea, ";
            strSql += " isnull(sum(t3.MechHarvestArea),0.00) MechHarvestArea, ";
            strSql += " isnull(cast(sum(t3.SeedCost)/(case when count(case when t3.SeedCost !=0 then 1 else null end) =0 then 1 else count(case when t3.SeedCost !=0 then 1 else null end) end) as decimal(10,1)),0.00) SeedCost,";
            strSql += " isnull(cast(sum(t3.FertilizerCost)/(case when count(case when t3.FertilizerCost !=0 then 1 else null end) =0 then 1 else count(case when t3.FertilizerCost !=0 then 1 else null end) end )as decimal(10,1)),0.00) FertilizerCost,";
            strSql += " isnull(cast(sum(t3.PesticideCost)/(case when count(case when t3.PesticideCost !=0 then 1 else null end) =0 then 1 else count(case when t3.PesticideCost !=0 then 1 else null end) end )as decimal(10,1)),0.00) PesticideCost,";
            strSql += " isnull(cast(sum(t3.MulchCost)/(case when count(case when t3.MulchCost !=0 then 1 else null end) =0 then 1 else count(case when t3.MulchCost !=0 then 1 else null end) end )as decimal(10,1)),0.00) MulchCost,";
            strSql += " isnull(cast(sum(t3.LaborCost)/(case when count(case when t3.LaborCost !=0 then 1 else null end) = 0 then 1 else count(case when t3.LaborCost !=0 then 1 else null end) end )as decimal(10,1)),0.00) LaborCost,";
            strSql += " isnull(cast(sum(t3.OtherCost)/(case when count(case when t3.OtherCost !=0 then 1 else null end) =0 then 1 else count(case when t3.OtherCost !=0 then 1 else null end) end )as decimal(10,1)),0.00) OtherCost,";
            strSql += " isnull(cast(sum(t3.TotalCost)/(case when count(case when t3.TotalCost !=0 then 1 else null end) = 0 then 1 else count(case when t3.TotalCost !=0 then 1 else null end) end) as decimal(10,1)),0.00) TotalCost,";
            strSql += " isnull(cast(sum(t3.OAvgMuYield)/(case when count(case when t3.OAvgMuYield !=0 then 1 else null end)= 0 then 1 else count(case when t3.OAvgMuYield !=0 then 1 else null end) end) as decimal(10,2)),0.00) OAvgMuYield,";
            strSql += " isnull(cast(sum(t3.OAvgPrice)/(case when count(case when t3.OAvgPrice !=0 then 1 else null end) = 0 then 1 else count(case when t3.OAvgPrice !=0 then 1 else null end) end )as decimal(10,1)),0.00) OAvgPrice,";
            strSql += " isnull(cast(sum(t3.OTotalOutput)/(case when count(case when t3.OTotalOutput !=0 then 1 else null end) = 0 then 1 else count(case when t3.OTotalOutput !=0 then 1 else null end) end)as decimal(10,1)),0.00) OTotalOutput,";
            strSql += " isnull(cast(sum(t3.Income)/(case when count(case when t3.Income !=0 then 1 else null end) =0 then 1 else count(case when t3.Income !=0 then 1 else null end) end) as decimal(10,1)),0.00) Income ";
            strSql += " from T_Area t1 left join ";
            strSql += " T_Report t2 on t2.AreaCode = t1.Code left join  ";
            strSql += " T_PotSeasonProduct t3 on t2.Id = t3.ReportId where t2.ReportCode = 'PotSeasonProduct'  and t2.FillInYear = @FillInYear  ";
            strSql += " and t2.TimesCycle= '" + TimesCycle + "'";
            strSql += " and t2.status=  '4' ";
            if (!String.IsNullOrEmpty(SeasonDict))
            {
                strSql += " and t3.SeasonDict = '"+ SeasonDict+"'";
            }
            strSql += " and (t1.ParentCode != '530000000000' or  t1.Code !='530000000000') ";
            strSql += " group by rollup(t1.ParentCode) ";
            strSql += " ) tt left join T_Area ta on tt.AreaCode = ta.Code";
            try
            {
                using (var dbCon = ConnectFactory.GetOpenConnection())
                {
                    list = dbCon.Query<SeasonProductStatisModel>(strSql, new { FillInYear = FillInYear }).ToList();
                    dbCon.Dispose();//数据库连接释放
                    if (list.Count > 0)
                    {
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (list[i].TotalArea != 0)
                            {
                                list[i].AvgMuYield = Decimal.Round((decimal)(list[i].TotalYield / list[i].TotalArea * 1000), 2);
                                list[i].MuOutput = Decimal.Round((decimal)(list[i].TotalOutput / list[i].TotalArea), 1);
                                list[i].SeedCoverage = Decimal.Round((decimal)(list[i].tdSeedArea / list[i].TotalArea * 100), 2);
                            }
                            if (list[i].JZArea != 0)
                            {
                                list[i].JZAvgMuYield = Decimal.Round((decimal)(list[i].JZYield / list[i].JZArea * 1000), 2);
                            }
                            if (list[i].JTArea != 0)
                            {
                                list[i].JTAvgMuYield = Decimal.Round((decimal)(list[i].JTYield / list[i].JTArea * 1000), 2);
                                list[i].JTMixMuYield = Decimal.Round((decimal)(list[i].JTMixYield / list[i].JTArea * 1000), 2);
                                list[i].JTMixMuOutput = Decimal.Round((decimal)(list[i].JTMixOutput / list[i].JTArea), 1);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return null;
                LogHelper.ErrorLog("获取马铃薯生产情况统计列表信息失败", ex);
            }
            return list;
        }
    
        public List<SeasonProductStatisModel>  getCityStatisList(string AreaCode,string FillInYear,string TimesCycle, string SeasonDict)
        {
            List<SeasonProductStatisModel> list = new List<SeasonProductStatisModel>();
            string strSql = "select  ta.FullName AreaName,tt.* from( ";
            strSql += "select case when grouping(t1.Code)=1 then '"+ AreaCode+"' else Code end AreaCode, ";
            strSql += " isnull(sum(t3.TotalArea),0.00) TotalArea, ";
            strSql += " isnull(sum(t3.TotalYield),0.00) TotalYield, ";
            strSql += " isnull(sum(t3.TotalOutput),0.00) TotalOutput, ";
            strSql += " isnull(sum(t3.tdSeedArea),0.00) tdSeedArea,";
            strSql += " isnull(sum(t3.MulchArea),0.00) MulchArea, ";
            strSql += " isnull(sum(t3.DripArea),0.00) DripArea, ";
            strSql += " isnull(sum(t3.FertilizerArea),0.00) FertilizerArea, ";
            strSql += " isnull(sum(t3.NoCultivationArea),0.00) NoCultivationArea, ";
            strSql += " isnull(sum(t3.JZArea),0.00) JZArea, ";
            strSql += " isnull(sum(t3.JZYield),0.00) JZYield,  ";
            strSql += " isnull(cast(sum(t3.JZArea*t3.JZMuOutput)as decimal(10,4)),0.00) JZOutput, ";
            strSql += " isnull(cast(sum(t3.JZDensity)/(case when count(case when t3.JZDensity !=0 then 1 else null end) = 0 then 1 else count(case when t3.JZDensity !=0 then 1 else null end) end )as decimal(10,2)),0.00) JZDensity,";
            strSql += " isnull(sum(t3.JTArea),0.00) JTArea, ";
            strSql += " isnull(sum(t3.JTYield),0.00) JTYield, ";
            strSql += " isnull(cast(sum(t3.JTArea*t3.JTMixMuYield/1000)as decimal(10,4)),0.00)JTMixYield, ";
            strSql += " isnull(cast(sum(t3.JTArea*t3.JTMixMuOutput)as decimal(10,4)),0.00)JTMixOutput,";
            strSql += " isnull(sum(t3.MechPlantArea),0.00) MechPlantArea, ";
            strSql += " isnull(sum(t3.MechCultivationArea),0.00) MechCultivationArea, ";
            strSql += " isnull(sum(t3.MechFertilizerArea),0.00) MechFertilizerArea, ";
            strSql += " isnull(sum(t3.MechPesticideArea),0.00) MechPesticideArea, ";
            strSql += " isnull(sum(t3.MechHarvestArea),0.00) MechHarvestArea, ";
            strSql += " isnull(cast(sum(t3.SeedCost)/(case when count(case when t3.SeedCost !=0 then 1 else null end) =0 then 1 else count(case when t3.SeedCost !=0 then 1 else null end) end) as decimal(10,1)),0.00) SeedCost,";
            strSql += " isnull(cast(sum(t3.FertilizerCost)/(case when count(case when t3.FertilizerCost !=0 then 1 else null end) =0 then 1 else count(case when t3.FertilizerCost !=0 then 1 else null end) end )as decimal(10,1)),0.00) FertilizerCost,";
            strSql += " isnull(cast(sum(t3.PesticideCost)/(case when count(case when t3.PesticideCost !=0 then 1 else null end) =0 then 1 else count(case when t3.PesticideCost !=0 then 1 else null end) end )as decimal(10,1)),0.00) PesticideCost,";
            strSql += " isnull(cast(sum(t3.MulchCost)/(case when count(case when t3.MulchCost !=0 then 1 else null end) =0 then 1 else count(case when t3.MulchCost !=0 then 1 else null end) end )as decimal(10,1)),0.00) MulchCost,";
            strSql += " isnull(cast(sum(t3.LaborCost)/(case when count(case when t3.LaborCost !=0 then 1 else null end) = 0 then 1 else count(case when t3.LaborCost !=0 then 1 else null end) end )as decimal(10,1)),0.00) LaborCost,";
            strSql += " isnull(cast(sum(t3.OtherCost)/(case when count(case when t3.OtherCost !=0 then 1 else null end) =0 then 1 else count(case when t3.OtherCost !=0 then 1 else null end) end )as decimal(10,1)),0.00) OtherCost,";
            strSql += " isnull(cast(sum(t3.TotalCost)/(case when count(case when t3.TotalCost !=0 then 1 else null end) = 0 then 1 else count(case when t3.TotalCost !=0 then 1 else null end) end) as decimal(10,1)),0.00) TotalCost,";
            strSql += " isnull(cast(sum(t3.OAvgMuYield)/(case when count(case when t3.OAvgMuYield !=0 then 1 else null end)= 0 then 1 else count(case when t3.OAvgMuYield !=0 then 1 else null end) end) as decimal(10,2)),0.00) OAvgMuYield,";
            strSql += " isnull(cast(sum(t3.OAvgPrice)/(case when count(case when t3.OAvgPrice !=0 then 1 else null end) = 0 then 1 else count(case when t3.OAvgPrice !=0 then 1 else null end) end )as decimal(10,1)),0.00) OAvgPrice,";
            strSql += " isnull(cast(sum(t3.OTotalOutput)/(case when count(case when t3.OTotalOutput !=0 then 1 else null end) = 0 then 1 else count(case when t3.OTotalOutput !=0 then 1 else null end) end)as decimal(10,1)),0.00) OTotalOutput,";
            strSql += " isnull(cast(sum(t3.Income)/(case when count(case when t3.Income !=0 then 1 else null end) =0 then 1 else count(case when t3.Income !=0 then 1 else null end) end) as decimal(10,1)),0.00) Income ";
            strSql += " from T_Area t1 left join ";
            strSql += " T_Report t2 on t2.AreaCode = t1.Code left join  ";
            strSql += " T_PotSeasonProduct t3 on t2.Id = t3.ReportId where t2.ReportCode = 'PotSeasonProduct' and t1.ParentCode =@AreaCode ";
            strSql += "  and t2.FillInYear = @FillInYear  ";
            strSql += "  and t2.status=  '4' ";
            if (!String.IsNullOrEmpty(TimesCycle) &&!TimesCycle.Equals("0"))
            {
                strSql += " and t2.TimesCycle= '"+TimesCycle+"'";
            }
            if (!String.IsNullOrEmpty(SeasonDict))
            {
                strSql += " and t3.SeasonDict = '" + SeasonDict + "'";
            }
            strSql += " group by rollup(t1.Code)";
            strSql += " ) tt left join T_Area ta on tt.AreaCode = ta.Code";
            try
                {
                    using (var dbCon = ConnectFactory.GetOpenConnection())
                    {
                        list = dbCon.Query<SeasonProductStatisModel>(strSql, new { AreaCode = AreaCode, FillInYear = FillInYear}).ToList();
                        dbCon.Dispose();//数据库连接释放
                        if (list.Count > 0)
                        {
                            for (int i = 0; i < list.Count; i++)
                            {
                                if (list[i].TotalArea != 0)
                                {
                                    list[i].AvgMuYield = Decimal.Round((decimal)(list[i].TotalYield / list[i].TotalArea*1000), 2);
                                    list[i].MuOutput = Decimal.Round((decimal)(list[i].TotalOutput / list[i].TotalArea), 1);
                                    list[i].SeedCoverage = Decimal.Round((decimal)(list[i].tdSeedArea / list[i].TotalArea * 100), 2);
                                }
                                if(list[i].JZArea != 0)
                                {
                                    list[i].JZAvgMuYield = Decimal.Round((decimal)(list[i].JZYield / list[i].JZArea * 1000), 2);
                                }
                                if(list[i].JTArea != 0)
                                {
                                    list[i].JTAvgMuYield = Decimal.Round((decimal)(list[i].JTYield / list[i].JTArea * 1000), 2);
                                list[i].JTMixMuYield = Decimal.Round((decimal)(list[i].JTMixYield / list[i].JTArea * 1000), 2);
                                list[i].JTMixMuOutput = Decimal.Round((decimal)(list[i].JTMixOutput / list[i].JTArea), 1);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    return null;
                    LogHelper.ErrorLog("获取马铃薯生产情况统计列表信息失败", ex);
                }
                return list;
        }

        public ResResult<List<List<AllYearStatisModel>>> GetAllYearStatisList(string AreaCode, string TimesCycle, string SeasonDict)
        {
            ResResult<List<List<AllYearStatisModel>>> obj = new ResResult<List<List<AllYearStatisModel>>>();
            
            List<List<AllYearStatisModel>> list = new List<List<AllYearStatisModel>>();
            AreaServices areaservices = new AreaServices();
            DictServices dictService = new DictServices();
            var yearList = dictService.GetYearList();
            var childAreaList = areaservices.getChildAreaCode(AreaCode);
            if (AreaCode.Equals("530000000000"))
            {
                foreach (var item in childAreaList)
                {
                    var statislist = GetAllYearCityData(item.Code,TimesCycle, SeasonDict);
                    var datalist = ParseData(yearList, statislist);
                    List<AllYearStatisModel> templist = new List<AllYearStatisModel>();
                    for (int i= 0;i< datalist.Count;i++)
                    {
                        var dataItem = datalist[i];
                        AllYearStatisModel model = new AllYearStatisModel();
                        model.AreaName = item.Name;
                        model.allYearDataList = dataItem;
                        templist.Add(model);
                    }
                    list.Add(templist);
                }
                var totalstatislist = GetAllYearProvinData(TimesCycle, SeasonDict);
                var totaldatalist = ParseData(yearList, totalstatislist);
                List<AllYearStatisModel> totaltemplist = new List<AllYearStatisModel>();
                for (int i = 0; i < totaldatalist.Count; i++)
                {
                    var dataItem = totaldatalist[i];
                    AllYearStatisModel model = new AllYearStatisModel();
                    model.AreaName = "全省";
                    model.allYearDataList = dataItem;
                    totaltemplist.Add(model);
                }
                list.Add(totaltemplist);
            }
            else if (AreaCode.Substring(4, 8).Equals("00000000"))
            {
                foreach (var item in childAreaList)
                {
                    var statislist = GetAllYearCountyData(item.Code, TimesCycle, SeasonDict);
                    var datalist = ParseData(yearList, statislist);
                    List<AllYearStatisModel> templist = new List<AllYearStatisModel>();
                    for (int i = 0; i < datalist.Count; i++)
                    {
                        var dataItem = datalist[i];
                        AllYearStatisModel model = new AllYearStatisModel();
                        model.AreaName = item.Name;
                        model.allYearDataList = dataItem;
                        templist.Add(model);
                    }
                    list.Add(templist);
                }
                var totalstatislist = GetAllYearCityData(AreaCode, TimesCycle, SeasonDict);
                var totaldatalist = ParseData(yearList, totalstatislist);
                List<AllYearStatisModel> totaltemplist = new List<AllYearStatisModel>();
                for (int i = 0; i < totaldatalist.Count; i++)
                {
                    var dataItem = totaldatalist[i];
                    AllYearStatisModel model = new AllYearStatisModel();
                    model.AreaName = "全州（市）";
                    model.allYearDataList = dataItem;
                    totaltemplist.Add(model);
                }
                list.Add(totaltemplist);
            }
            obj.model = list;
            obj.status = DefaultKey.SuccessResult;
            obj.message = "获取成功";
            return obj;
        }
        /// <summary>
        /// 获取区县级所有年份统计数据
        /// </summary>
        /// <param name="AreaCode"></param>
        /// <param name="TimesCycle"></param>
        /// <param name="SeasonDict"></param>
        /// <returns></returns>
        public List<SeasonProductStatisModel> GetAllYearCountyData(string AreaCode,string TimesCycle, string SeasonDict)
        {
            List<SeasonProductStatisModel> list = new List<SeasonProductStatisModel>();
            string strSql = "select t1.Name AreaName,t4.DictValue FillInYear,t3.* ";
            strSql += " from T_Area t1 left join ";
            strSql += " T_Report t2 on t2.AreaCode = t1.Code left join ";
            strSql += " T_PotSeasonProduct t3 on t2.Id = t3.ReportId right join T_Dict t4 on t2.FillInYear = t4.DictValue";
            strSql += " where t2.ReportCode = 'PotSeasonProduct' and t2.AreaCode = @AreaCode ";
            strSql += " and GroupCode='ReportYear' and t4.DictText !='全部' ";
            strSql += "  and t2.status=  '4' ";
            
            if (!String.IsNullOrEmpty(TimesCycle))
            {
                strSql += " and t2.TimesCycle= '" + TimesCycle + "'";
            }
            if (!String.IsNullOrEmpty(SeasonDict))
            {
                strSql += " and t3.SeasonDict = '" + SeasonDict + "'";
            }
            strSql += " order by t4.DictValue asc";
            try
            {
                using (var dbCon = ConnectFactory.GetOpenConnection())
                {
                    list = dbCon.Query<SeasonProductStatisModel>(strSql, new { AreaCode = AreaCode}).ToList();
                    dbCon.Dispose();//数据库连接释放
                }
            }
            catch (Exception ex)
            {
                return null;
                LogHelper.ErrorLog("获取马铃薯生产情况统计列表信息失败", ex);
            }
            return list;
        }
        /// <summary>
        /// 分解属性成各个列表，共38个前端所需显示指标列表
        /// </summary>
        /// <param name="YearList"></param>
        /// <param name="DataList"></param>
        /// <returns></returns>
        public List<List<decimal?>> ParseData(List<string> YearList,List<SeasonProductStatisModel> DataList)
        {
            List<List<decimal?>> list = new List<List<decimal?>>();
            List<decimal?> list1 = new List<decimal?>(),
                list2 = new List<decimal?>(),list3 = new List<decimal?>(),
                list4 = new List<decimal?>(), list5 = new List<decimal?>(), 
                list6 = new List<decimal?>(), list7 = new List<decimal?>(), 
                list8 = new List<decimal?>(), list9 = new List<decimal?>(), 
                list10 = new List<decimal?>(), list11 = new List<decimal?>(), 
                list12 = new List<decimal?>(), list13 = new List<decimal?>(), 
                list14 = new List<decimal?>(), list15 = new List<decimal?>(),
                list16 = new List<decimal?>(), list17 = new List<decimal?>(), 
                list18 = new List<decimal?>(), list19 = new List<decimal?>(), 
                list20 = new List<decimal?>(),list21 = new List<decimal?>(), 
                list22 = new List<decimal?>(), list23 = new List<decimal?>(), 
                list24 = new List<decimal?>(), list25 = new List<decimal?>(), 
                list26 = new List<decimal?>(), list27 = new List<decimal?>(), 
                list28 = new List<decimal?>(), list29 = new List<decimal?>(), 
                list30 = new List<decimal?>(), list31 = new List<decimal?>(), 
                list32 = new List<decimal?>(), list33 = new List<decimal?>(), 
                list34 = new List<decimal?>(), list35 = new List<decimal?>(),
                list36 = new List<decimal?>(), list37 = new List<decimal?>(), list38= new List<decimal?>();

            foreach(var year in YearList)
            {
                decimal? temp1=0, temp2= 0,temp3= 0,temp4= 0,temp5= 0,temp6= 0,temp7= 0,temp8= 0,temp9= 0,temp10= 0,temp11= 0,temp12= 0,temp13= 0,temp14= 0,temp15= 0,temp16= 0,temp17= 0,temp18 = 0,
                temp19= 0,temp20= 0,temp21= 0,temp22= 0,temp23= 0,temp24= 0,temp25= 0,temp26= 0,temp27= 0,temp28= 0,temp29= 0,temp30= 0,temp31= 0,temp32= 0,temp33=0,
                temp34= 0,temp35= 0,temp36= 0,temp37= 0,temp38 = 0 ;
                if (DataList != null && DataList.Count > 0)
                {
                    for (int i = 0; i < DataList.Count; i++)
                    {
                        var Item = DataList[i];
                        if (Item.FillInYear.Equals(year))
                        {
                            temp1 = Item.TotalArea;
                            temp2 = Item.TotalYield;
                            temp3 = Item.AvgMuYield;
                            temp4 = Item.MuOutput;
                            temp5 = Item.TotalOutput;
                            temp6 = Item.tdSeedArea;
                            temp7 = Item.SeedCoverage;
                            temp8 = Item.MulchArea;
                            temp9 = Item.DripArea;
                            temp10 = Item.FertilizerArea;
                            temp11 = Item.NoCultivationArea;

                            temp12 = Item.JZArea;
                            temp13 = Item.JZYield;
                            temp14 = Item.JZAvgMuYield;
                            temp15 = Item.JZOutput;
                            temp16 = Item.JZMuOutput;
                            temp17 = Item.JZDensity;

                            temp18 = Item.JTArea;
                            temp19 = Item.JTYield;
                            temp20 = Item.JTAvgMuYield;
                            temp21 = Item.JTMixYield;
                            temp22 = Item.JTMixMuYield;
                            temp23 = Item.JTMixMuOutput;

                            temp24 = Item.MechPlantArea;
                            temp25 = Item.MechCultivationArea;
                            temp26 = Item.MechFertilizerArea;
                            temp27 = Item.MechPesticideArea;
                            temp28 = Item.MechHarvestArea;

                            temp29 = Item.SeedCost;
                            temp30 = Item.FertilizerCost;
                            temp31 = Item.PesticideCost;
                            temp32 = Item.MulchCost;
                            temp33 = Item.LaborCost;
                            temp34 = Item.OtherCost;
                            temp35 = Item.TotalCost;
                            temp36 = Item.OAvgPrice;
                            temp37 = Item.OTotalOutput;
                            temp38 = Item.Income;

                            DataList.Remove(Item);//将匹配到的项去掉，加快匹配速度
                        }
                    }
                }
                list1.Add(temp1);   list2.Add(temp2);   list3.Add(temp3);   list4.Add(temp4);   list5.Add(temp5);   list6.Add(temp6);
                list7.Add(temp7);   list8.Add(temp8);   list9.Add(temp9);   list10.Add(temp10); list11.Add(temp11); list12.Add(temp12);
                list13.Add(temp13); list14.Add(temp14); list15.Add(temp15); list16.Add(temp16);list17.Add(temp17); list18.Add(temp18);
                list19.Add(temp19); list20.Add(temp20); list21.Add(temp21); list22.Add(temp22); list23.Add(temp23);list24.Add(temp24);
                list25.Add(temp25); list26.Add(temp26); list27.Add(temp27); list28.Add(temp28);list29.Add(temp29);list30.Add(temp30);
                list31.Add(temp31); list32.Add(temp32); list33.Add(temp33);list34.Add(temp34);list35.Add(temp35);list36.Add(temp36);
                list37.Add(temp37); list38.Add(temp38);
            }
            //按顺序加入list
            list.Add(list1); list.Add(list2); list.Add(list3); list.Add(list4); list.Add(list5); list.Add(list6); list.Add(list7);
            list.Add(list8); list.Add(list9); list.Add(list10); list.Add(list11); list.Add(list12); list.Add(list13); list.Add(list14);
            list.Add(list15); list.Add(list16); list.Add(list17); list.Add(list18); list.Add(list19); list.Add(list20); list.Add(list21);
            list.Add(list22); list.Add(list23); list.Add(list24); list.Add(list25); list.Add(list26); list.Add(list27); list.Add(list28);
            list.Add(list29); list.Add(list30); list.Add(list31); list.Add(list32); list.Add(list33); list.Add(list34); list.Add(list35); list.Add(list36);
            list.Add(list37); list.Add(list38);

            return list;
        }
       
        /// <summary>
        /// 获取州市级所有年份统计数据
        /// </summary>
        /// <param name="AreaCode"></param>
        /// <param name="TimesCycle"></param>
        /// <param name="SeasonDict"></param>
        /// <returns></returns>
        public List<SeasonProductStatisModel> GetAllYearCityData(string AreaCode, string TimesCycle, string SeasonDict)
        {
            List<SeasonProductStatisModel> list = new List<SeasonProductStatisModel>();
            string strSql = "select t4.DictValue FillInYear, ";
            strSql += " isnull(sum(t3.TotalArea),0.00) TotalArea, ";
            strSql += " isnull(sum(t3.TotalYield),0.00) TotalYield, ";
            strSql += " isnull(sum(t3.TotalOutput),0.00) TotalOutput, ";
            strSql += " isnull(sum(t3.tdSeedArea),0.00) tdSeedArea,";
            strSql += " isnull(sum(t3.MulchArea),0.00) MulchArea, ";
            strSql += " isnull(sum(t3.DripArea),0.00) DripArea, ";
            strSql += " isnull(sum(t3.FertilizerArea),0.00) FertilizerArea, ";
            strSql += " isnull(sum(t3.NoCultivationArea),0.00) NoCultivationArea, ";
            strSql += " isnull(sum(t3.JZArea),0.00) JZArea, ";
            strSql += " isnull(sum(t3.JZYield),0.00) JZYield,  ";
            strSql += " isnull(cast(sum(t3.JZArea*t3.JZMuOutput)as decimal(10,4)),0.00) JZOutput, ";
            strSql += " isnull(cast(sum(t3.JZDensity)/(case when count(case when t3.JZDensity !=0 then 1 else null end) = 0 then 1 else count(case when t3.JZDensity !=0 then 1 else null end) end )as decimal(10,2)),0.00) JZDensity,";
            strSql += " isnull(sum(t3.JTArea),0.00) JTArea, ";
            strSql += " isnull(sum(t3.JTYield),0.00) JTYield, ";
            strSql += " isnull(cast(sum(t3.JTArea*t3.JTMixMuYield/1000)as decimal(10,4)),0.00)JTMixYield, ";
            strSql += " isnull(cast(sum(t3.JTArea*t3.JTMixMuOutput)as decimal(10,4)),0.00)JTMixOutput,";
            strSql += " isnull(sum(t3.MechPlantArea),0.00) MechPlantArea, ";
            strSql += " isnull(sum(t3.MechCultivationArea),0.00) MechCultivationArea, ";
            strSql += " isnull(sum(t3.MechFertilizerArea),0.00) MechFertilizerArea, ";
            strSql += " isnull(sum(t3.MechPesticideArea),0.00) MechPesticideArea, ";
            strSql += " isnull(sum(t3.MechHarvestArea),0.00) MechHarvestArea, ";
            strSql += " isnull(cast(sum(t3.SeedCost)/(case when count(case when t3.SeedCost !=0 then 1 else null end) =0 then 1 else count(case when t3.SeedCost !=0 then 1 else null end) end) as decimal(10,1)),0.00) SeedCost,";
            strSql += " isnull(cast(sum(t3.FertilizerCost)/(case when count(case when t3.FertilizerCost !=0 then 1 else null end) =0 then 1 else count(case when t3.FertilizerCost !=0 then 1 else null end) end )as decimal(10,1)),0.00) FertilizerCost,";
            strSql += " isnull(cast(sum(t3.PesticideCost)/(case when count(case when t3.PesticideCost !=0 then 1 else null end) =0 then 1 else count(case when t3.PesticideCost !=0 then 1 else null end) end )as decimal(10,1)),0.00) PesticideCost,";
            strSql += " isnull(cast(sum(t3.MulchCost)/(case when count(case when t3.MulchCost !=0 then 1 else null end) =0 then 1 else count(case when t3.MulchCost !=0 then 1 else null end) end )as decimal(10,1)),0.00) MulchCost,";
            strSql += " isnull(cast(sum(t3.LaborCost)/(case when count(case when t3.LaborCost !=0 then 1 else null end) = 0 then 1 else count(case when t3.LaborCost !=0 then 1 else null end) end )as decimal(10,1)),0.00) LaborCost,";
            strSql += " isnull(cast(sum(t3.OtherCost)/(case when count(case when t3.OtherCost !=0 then 1 else null end) =0 then 1 else count(case when t3.OtherCost !=0 then 1 else null end) end )as decimal(10,1)),0.00) OtherCost,";
            strSql += " isnull(cast(sum(t3.TotalCost)/(case when count(case when t3.TotalCost !=0 then 1 else null end) = 0 then 1 else count(case when t3.TotalCost !=0 then 1 else null end) end) as decimal(10,1)),0.00) TotalCost,";
            strSql += " isnull(cast(sum(t3.OAvgMuYield)/(case when count(case when t3.OAvgMuYield !=0 then 1 else null end)= 0 then 1 else count(case when t3.OAvgMuYield !=0 then 1 else null end) end) as decimal(10,2)),0.00) OAvgMuYield,";
            strSql += " isnull(cast(sum(t3.OAvgPrice)/(case when count(case when t3.OAvgPrice !=0 then 1 else null end) = 0 then 1 else count(case when t3.OAvgPrice !=0 then 1 else null end) end )as decimal(10,1)),0.00) OAvgPrice,";
            strSql += " isnull(cast(sum(t3.OTotalOutput)/(case when count(case when t3.OTotalOutput !=0 then 1 else null end) = 0 then 1 else count(case when t3.OTotalOutput !=0 then 1 else null end) end)as decimal(10,1)),0.00) OTotalOutput,";
            strSql += " isnull(cast(sum(t3.Income)/(case when count(case when t3.Income !=0 then 1 else null end) =0 then 1 else count(case when t3.Income !=0 then 1 else null end) end) as decimal(10,1)),0.00) Income ";
            strSql += " from T_Area t1 left join ";
            strSql += " T_Report t2 on t2.AreaCode = t1.Code left join  ";
            strSql += " T_PotSeasonProduct t3 on t2.Id = t3.ReportId right join T_Dict t4 on t2.FillInYear = t4.DictValue ";
            strSql += "  where t2.ReportCode = 'PotSeasonProduct' and t1.ParentCode =@AreaCode ";
            strSql += " and GroupCode='ReportYear' and t4.DictText !='全部' ";
            strSql += "  and t2.status=  '4' ";
            if (!String.IsNullOrEmpty(TimesCycle))
            {
                strSql += " and t2.TimesCycle= '" + TimesCycle + "'";
            }
            if (!String.IsNullOrEmpty(SeasonDict))
            {
                strSql += " and t3.SeasonDict = '" + SeasonDict + "'";
            }
            strSql += " group by t4.DictValue  order by t4.DictValue asc";
            try
            {
                using (var dbCon = ConnectFactory.GetOpenConnection())
                {
                    list = dbCon.Query<SeasonProductStatisModel>(strSql, new { AreaCode = AreaCode}).ToList();
                    dbCon.Dispose();//数据库连接释放
                    if (list.Count > 0)
                    {
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (list[i].TotalArea != 0)
                            {
                                list[i].AvgMuYield = Decimal.Round((decimal)(list[i].TotalYield / list[i].TotalArea * 1000), 2);
                                list[i].MuOutput = Decimal.Round((decimal)(list[i].TotalOutput / list[i].TotalArea), 1);
                                list[i].SeedCoverage = Decimal.Round((decimal)(list[i].tdSeedArea / list[i].TotalArea * 100), 2);
                            }
                            if (list[i].JZArea != 0)
                            {
                                list[i].JZAvgMuYield = Decimal.Round((decimal)(list[i].JZYield / list[i].JZArea * 1000), 2);
                            }
                            if (list[i].JTArea != 0)
                            {
                                list[i].JTAvgMuYield = Decimal.Round((decimal)(list[i].JTYield / list[i].JTArea * 1000), 2);
                                list[i].JTMixMuYield = Decimal.Round((decimal)(list[i].JTMixYield / list[i].JTArea * 1000), 2);
                                list[i].JTMixMuOutput = Decimal.Round((decimal)(list[i].JTMixOutput / list[i].JTArea), 1);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return null;
                LogHelper.ErrorLog("获取马铃薯生产情况统计列表信息失败", ex);
            }
            return list;
        }

        /// <summary>
        /// 获取全省所有年度统计数据
        /// </summary>
        /// <param name="TimesCycle"></param>
        /// <param name="SeasonDict"></param>
        /// <returns></returns>
        public List<SeasonProductStatisModel> GetAllYearProvinData(string TimesCycle, string SeasonDict)
        {
            List<SeasonProductStatisModel> list = new List<SeasonProductStatisModel>();
            string strSql = "select t4.DictValue FillInYear, ";
            strSql += " isnull(sum(t3.TotalArea),0.00) TotalArea, ";
            strSql += " isnull(sum(t3.TotalYield),0.00) TotalYield, ";
            strSql += " isnull(sum(t3.TotalOutput),0.00) TotalOutput, ";
            strSql += " isnull(sum(t3.tdSeedArea),0.00) tdSeedArea,";
            strSql += " isnull(sum(t3.MulchArea),0.00) MulchArea, ";
            strSql += " isnull(sum(t3.DripArea),0.00) DripArea, ";
            strSql += " isnull(sum(t3.FertilizerArea),0.00) FertilizerArea, ";
            strSql += " isnull(sum(t3.NoCultivationArea),0.00) NoCultivationArea, ";
            strSql += " isnull(sum(t3.JZArea),0.00) JZArea, ";
            strSql += " isnull(sum(t3.JZYield),0.00) JZYield,  ";
            strSql += " isnull(cast(sum(t3.JZArea*t3.JZMuOutput)as decimal(10,4)),0.00) JZOutput, ";
            strSql += " isnull(cast(sum(t3.JZDensity)/(case when count(case when t3.JZDensity !=0 then 1 else null end) = 0 then 1 else count(case when t3.JZDensity !=0 then 1 else null end) end )as decimal(10,2)),0.00) JZDensity,";
            strSql += " isnull(sum(t3.JTArea),0.00) JTArea, ";
            strSql += " isnull(sum(t3.JTYield),0.00) JTYield, ";
            strSql += " isnull(cast(sum(t3.JTArea*t3.JTMixMuYield/1000)as decimal(10,4)),0.00)JTMixYield, ";
            strSql += " isnull(cast(sum(t3.JTArea*t3.JTMixMuOutput)as decimal(10,4)),0.00)JTMixOutput,";
            strSql += " isnull(sum(t3.MechPlantArea),0.00) MechPlantArea, ";
            strSql += " isnull(sum(t3.MechCultivationArea),0.00) MechCultivationArea, ";
            strSql += " isnull(sum(t3.MechFertilizerArea),0.00) MechFertilizerArea, ";
            strSql += " isnull(sum(t3.MechPesticideArea),0.00) MechPesticideArea, ";
            strSql += " isnull(sum(t3.MechHarvestArea),0.00) MechHarvestArea, ";
            strSql += " isnull(cast(sum(t3.SeedCost)/(case when count(case when t3.SeedCost !=0 then 1 else null end) =0 then 1 else count(case when t3.SeedCost !=0 then 1 else null end) end) as decimal(10,1)),0.00) SeedCost,";
            strSql += " isnull(cast(sum(t3.FertilizerCost)/(case when count(case when t3.FertilizerCost !=0 then 1 else null end) =0 then 1 else count(case when t3.FertilizerCost !=0 then 1 else null end) end )as decimal(10,1)),0.00) FertilizerCost,";
            strSql += " isnull(cast(sum(t3.PesticideCost)/(case when count(case when t3.PesticideCost !=0 then 1 else null end) =0 then 1 else count(case when t3.PesticideCost !=0 then 1 else null end) end )as decimal(10,1)),0.00) PesticideCost,";
            strSql += " isnull(cast(sum(t3.MulchCost)/(case when count(case when t3.MulchCost !=0 then 1 else null end) =0 then 1 else count(case when t3.MulchCost !=0 then 1 else null end) end )as decimal(10,1)),0.00) MulchCost,";
            strSql += " isnull(cast(sum(t3.LaborCost)/(case when count(case when t3.LaborCost !=0 then 1 else null end) = 0 then 1 else count(case when t3.LaborCost !=0 then 1 else null end) end )as decimal(10,1)),0.00) LaborCost,";
            strSql += " isnull(cast(sum(t3.OtherCost)/(case when count(case when t3.OtherCost !=0 then 1 else null end) =0 then 1 else count(case when t3.OtherCost !=0 then 1 else null end) end )as decimal(10,1)),0.00) OtherCost,";
            strSql += " isnull(cast(sum(t3.TotalCost)/(case when count(case when t3.TotalCost !=0 then 1 else null end) = 0 then 1 else count(case when t3.TotalCost !=0 then 1 else null end) end) as decimal(10,1)),0.00) TotalCost,";
            strSql += " isnull(cast(sum(t3.OAvgMuYield)/(case when count(case when t3.OAvgMuYield !=0 then 1 else null end)= 0 then 1 else count(case when t3.OAvgMuYield !=0 then 1 else null end) end) as decimal(10,2)),0.00) OAvgMuYield,";
            strSql += " isnull(cast(sum(t3.OAvgPrice)/(case when count(case when t3.OAvgPrice !=0 then 1 else null end) = 0 then 1 else count(case when t3.OAvgPrice !=0 then 1 else null end) end )as decimal(10,1)),0.00) OAvgPrice,";
            strSql += " isnull(cast(sum(t3.OTotalOutput)/(case when count(case when t3.OTotalOutput !=0 then 1 else null end) = 0 then 1 else count(case when t3.OTotalOutput !=0 then 1 else null end) end)as decimal(10,1)),0.00) OTotalOutput,";
            strSql += " isnull(cast(sum(t3.Income)/(case when count(case when t3.Income !=0 then 1 else null end) =0 then 1 else count(case when t3.Income !=0 then 1 else null end) end) as decimal(10,1)),0.00) Income ";
            strSql += " from T_Area t1 left join ";
            strSql += " T_Report t2 on t2.AreaCode = t1.Code left join  ";
            strSql += " T_PotSeasonProduct t3 on t2.Id = t3.ReportId right join T_Dict t4 on t2.FillInYear = t4.DictValue ";
            strSql += "  where t2.ReportCode = 'PotSeasonProduct' and t1.ParentCode !='530000000000'  and t1.ParentCode is not null ";
            strSql += " and GroupCode='ReportYear' and t4.DictText !='全部' ";
            strSql += "  and t2.status=  '4' ";
            if (!String.IsNullOrEmpty(TimesCycle))
            {
                strSql += " and t2.TimesCycle= '" + TimesCycle + "'";
            }
            if (!String.IsNullOrEmpty(SeasonDict))
            {
                strSql += " and t3.SeasonDict = '" + SeasonDict + "'";
            }
            strSql += " group by t4.DictValue  order by t4.DictValue asc";
            try
            {
                using (var dbCon = ConnectFactory.GetOpenConnection())
                {
                    list = dbCon.Query<SeasonProductStatisModel>(strSql).ToList();
                    dbCon.Dispose();//数据库连接释放
                    if (list.Count > 0)
                    {
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (list[i].TotalArea != 0)
                            {
                                list[i].AvgMuYield = Decimal.Round((decimal)(list[i].TotalYield / list[i].TotalArea * 1000), 2);
                                list[i].MuOutput = Decimal.Round((decimal)(list[i].TotalOutput / list[i].TotalArea), 1);
                                list[i].SeedCoverage = Decimal.Round((decimal)(list[i].tdSeedArea / list[i].TotalArea * 100), 2);
                            }
                            if (list[i].JZArea != 0)
                            {
                                list[i].JZAvgMuYield = Decimal.Round((decimal)(list[i].JZYield / list[i].JZArea * 1000), 2);
                            }
                            if (list[i].JTArea != 0)
                            {
                                list[i].JTAvgMuYield = Decimal.Round((decimal)(list[i].JTYield / list[i].JTArea * 1000), 2);
                                list[i].JTMixMuYield = Decimal.Round((decimal)(list[i].JTMixYield / list[i].JTArea * 1000), 2);
                                list[i].JTMixMuOutput = Decimal.Round((decimal)(list[i].JTMixOutput / list[i].JTArea), 1);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return null;
                LogHelper.ErrorLog("获取马铃薯生产情况统计列表信息失败", ex);
            }
            return list;
        }


    }
}